import {
  Modal,
  message
} from 'antd'
const confirm = Modal.confirm;

//打开部门页面
const openDepartment = (value) => {
  let url = '/spa/hrm/engine.html#/hrmengine/organization?'+'showTree='+false+'&type=department&id='+value;
  window.open(url);
}

//打开分部页面
const openSubcompany = (value) => {
  let url = '/spa/hrm/engine.html#/hrmengine/organization?'+'showTree='+false+'&type=subcompany&id='+value;
  window.open(url);
}

//打开人力页面
const openHrm = (value) => {
  let url = '/spa/hrm/index_mobx.html#/main/hrm/card/cardInfo/'+value;
  window.open(url);
}

//打开客户页面
const openCrm = (value) => {
  let url = '/spa/crm/mobx/index.html#/main/crm/customerView?customerId='+value;
  window.open(url);
}

//打开项目页面
const openPrj = (value) => {
  let url = '/spa/prj/index.html#/main/prj/projectCard?prjid='+value;
  window.open(url);
}

const openUrl = (redirectUrl,width,height) => {
  var iTop = (window.screen.availHeight-30-height)/2;
  var iLeft = (window.screen.availWidth-10-width)/2;
  let szFeatures = "top="+iTop+"," ;
  szFeatures +="left="+iLeft+"," ;
  szFeatures +="width="+width+"," ;
  szFeatures +="height="+height+"," ;
  szFeatures +="directories=no," ;
  szFeatures +="status=yes," ;
  szFeatures +="menubar=no," ;
  szFeatures +="location=no," ;
  if (height <= 600 ) szFeatures +="scrollbars=yes," ;
  else szFeatures +="scrollbars=no," ;
  szFeatures +="resizable=yes" ; //channelmode
  window.open(redirectUrl,"_blank",szFeatures) ;
}

//打开流程的路径
const openWorkFlowPath = (workflowId,width,height) => {
  let url = '/spa/workflow/static4engine/engine.html#/main/workflowengine/path/pathSet/pathDetail/baseSet/baseInfo?';
  url = url+'workflowId='+workflowId+'&showLeftTree=false'+'&_key='+workflowId;
  openUrl(url,width,height);
}

//打开流程
const openWorkFlow = (requestid,width,height) => {
  let url = "/workflow/request/ViewRequestForwardSPA.jsp?requestid="+requestid;
  window.open(url,"_blank") ;
}

export {
  openDepartment,
  openSubcompany,
  openHrm,
  openCrm,
  openPrj,
  openWorkFlow,
  openWorkFlowPath,
  openUrl
}